﻿
using Microsoft.EntityFrameworkCore;
using WebDemo.Data;

namespace WebDemo.MiddleWares
{
    public static class UseApplicationMigrateExtension
    {
        public static void UseAppContextMigration<TContext>(this WebApplication app) where TContext : MySQLDbContext
        {

            using var serviceScope = app.Services.CreateScope();
            var context = serviceScope.ServiceProvider.GetRequiredService<MySQLDbContext>();
            //context.Database.EnsureCreated();
            context.Database.Migrate();
        }
    }
}
